package com.ruibang.glass.produce.controller.lh;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.domain.req.GlassFluorescenceReq;
import com.ruibang.glass.produce.entity.GlassFluorescence;
import com.ruibang.glass.produce.service.GlassFluorescenceService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;


/**
 * <p>
 * 生产-理化-X荧光填写 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-03-12
 */
@RestController

@RequestMapping("/api/glass/produce/lh/glassFluorescence")
@Api(value = "生产-理化-X荧光填写控制器", tags = {"生产-理化-X荧光填写接口"})
public class GlassFluorescenceController {
    @Autowired
    private GlassFluorescenceService glassFluorescenceService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取生产-理化-X荧光填写", notes = "获取生产-理化-X荧光填写")
    public ResultBody getById(@PathVariable(value = "id") String id) {
        return ResultBody.success(glassFluorescenceService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增生产-理化-X荧光填写", notes = "新增生产-理化-X荧光填写")
    public ResultBody save(@RequestBody GlassFluorescence glassFluorescence) {
        glassFluorescenceService.saveInfo(glassFluorescence);
        return ResultBody.success();
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除生产-理化-X荧光填写", notes = "通过ID删除生产-理化-X荧光填写")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        glassFluorescenceService.delete(id);
        return ResultBody.success();
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改生产-理化-X荧光填写", notes = "修改生产-理化-X荧光填写")
    public ResultBody edit(@RequestBody GlassFluorescence glassFluorescence) {
        glassFluorescenceService.edit(glassFluorescence);
        return ResultBody.success();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询生产-理化-X荧光填写", notes = "分页列表查询生产-理化-X荧光填写")
    public ResultBody<IPage<GlassFluorescence>> pageQuery(@RequestBody GlassFluorescenceReq glassFluorescenceReq) {
        return ResultBody.success(glassFluorescenceService.pageQuery(glassFluorescenceReq));
    }

    @PostMapping("/reportForm")
    @ApiOperation(value = "玻璃成分报表(X荧光)")
    public ResultBody reportForm(@RequestBody GlassFluorescenceReq glassFluorescenceReq) {
        return glassFluorescenceService.reportForm(glassFluorescenceReq);
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出")
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 4, target = FrequencyControl.Target.IP)
    public void export(@RequestBody GlassFluorescenceReq glassFluorescenceReq, HttpServletResponse response) {
        glassFluorescenceService.export(glassFluorescenceReq, response);
    }

    @PostMapping("/exportReport")
    @ApiOperation(value = "导出报表")
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 4, target = FrequencyControl.Target.IP)
    public void exportReport(@RequestBody GlassFluorescenceReq glassFluorescenceReq, HttpServletResponse response) {
        glassFluorescenceService.exportReport(glassFluorescenceReq, response);
    }


}
